/*
2021-8-17
https://www.acwing.com/problem/content/1118/
*/
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;
const int N=10;
int n,m,x,y;
bool st[N][N];
int dx[8] = {-2, -1, 1, 2, 2, 1, -1, -2};
int dy[8] = {1, 2, 2, 1, -1, -2, -2, -1};

int dfs(int x,int y,int cnt)
{
    int res=0;
    if(cnt==n*m)
    {
        return 1;
    }
    st[x][y]=true;
    
    for(int i=0;i<8;i++)
    {
        int a=x+dx[i],b=y+dy[i];
        if(a<0||a>=n||b<0||b>=m) continue;
        if(st[a][b]) continue;
        res+=dfs(a,b,cnt+1);
    }
    st[x][y]=false;
    return res;
}

int main()
{
    int T;
    cin>>T;
    
    while(T--)
    {
        cin>>n>>m>>x>>y;
        cout<<dfs(x,y,1)<<endl;
    }
    
    return 0;
}
